<div class="layui-form" lay-filter="layuiadmin-form-role" id="form">
	<div class="form-cont">
		<div class="layui-form-item verify">
		  <label class="layui-form-label">分组名称</label>
		  <div class="layui-input-block">
			  <input type="text" lay-verify="required" autocomplete="off" verify='requirel2' v-model="detail.agent_group_name" placeholder="请输入分组名称" class="layui-input">
			  <span class="hint">分组名称必填</span>
			</div>
		</div>
	</div>
  
  <div class="form-btn" v-if="type!=3">
      <input type="button" value="保存" class="layui-btn" @click="submit">
  </div>
</div>

<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var form=new Vue({
	  		el:'#form',
	  		data:{
	  			detail:{
					
				},
				old_detail:{},
	  			qx:[],
				type:layui.admin.objData.type
	  		},
	  		created() {
				//初始化
	  			if(this.type!=1) this.detail=layui.admin.objData.detail,this.old_detail=JSON.stringify(layui.admin.objData.detail);
				//提交form
				var _this=this;
	  		},
	  		methods:{
				submit(){
					if(layui.admin.form('#form')){
						if(this.type==2){   //编辑
							var data=layui.admin.filter(this.detail,JSON.parse(this.old_detail),'group_id');
							if(data){
								layui.admin.formapi('agents/group_update',data);
							}
						}else{  //添加
							layui.admin.formapi('agents/group_add',this.detail);
						}
					}
				}
	  		}
	  	})
	});
</script>
